import * as reducerType from '../reducers/reducerType';
import axios from 'axios';
export function login (data) {
  console.error('触发此函数', data)
  return {type: reducerType.LOGIN, payload: data}
}

export function addGun () {
  return { type: reducerType.ADD }
}
export function removeGun () {
  return { type: reducerType.LESS }
}

export function getUserData () {
  // console.log('打印参数', arguments)
  return dispatch => {
      axios.get('http://192.168.1.135:8000/data.json').then(res => {
          if (res.status === 200) {
              dispatch(login(res.data.data))
          }
      })
  }
}

export function handleLogin (data = {name: 'chenming'}) {
  login(data)
}